package com.example.myapplication;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import java.util.List;

public class ToAdapter extends ArrayAdapter {
    private final int resourceId;

    public ToAdapter(Context context, int textViewResourceId, List<To> object){
        super(context,textViewResourceId,object);
        resourceId = textViewResourceId;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        To to = (To)getItem(position);
        View view = LayoutInflater.from(getContext()).inflate(resourceId,null);
        TextView toName = (TextView) view.findViewById(R.id.to_name);
        toName.setText(to.getName());
        return view;
    }
}
